package com.gx.smart.construction.ui.login.bind;

import androidx.databinding.BindingAdapter;

import com.google.android.material.tabs.TabLayout;
import com.gx.smart.construction.ui.login.viewmodel.LoginViewModel;

/**
 * @author: xiaosy
 * 时间: 2022/1/20
 * @Description: tab切换
 * @Version: 1.0
 **/
public class TabLayoutBindAdapter {
    @BindingAdapter("onTabSelected")
    public static void onTabSelected(TabLayout tabLayout, LoginViewModel viewModel){
        tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                viewModel.tabIndex.set(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }
}
